﻿//https://leetcode.cn/problems/group-anagrams/submissions/585057455/?envType=study-plan-v2&envId=top-100-liked

class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs)
    {
        unordered_map<string, vector<string>> hash;
        for (auto& s : strs)
        {
            string temp = s;
            sort(temp.begin(), temp.end());
            hash[temp].push_back(s);  //每一个字符串排完序之后如果是相同的 就放入同一个数组
        }

        vector<vector<string>> ret;
        for (auto& [x, y] : hash)
        {
            ret.push_back(y);
        }
        return ret;

    }
};